home *** CD-ROM | disk | FTP | other *** search
File List | 1991-08-11 | 11.2 KB | 253 lines |
-
- Motorola DSP56000 Macro Cross Assembler Version 2.02 91-08-11 13:44:22 fft.asm Page 1
-
-
-
- 1 page 132,63,1,1
- 2 opt rc
- 4
- 5 ;***************************************************************
- 6 ;* FFT.ASM -- FFT transform, periodogram calculation and *
- 7 ;* main control loop *
- 8 ;* *
- 9 ;* Provides main control loop of the FFT based periodogram *
- 10 ;* spectrum analyzer. *
- 11 ;* *
- 12 ;* Periodogram calculation is based on the book: *
- 13 ;* Oppenheim, A, Shafer, R.: *
- 14 ;* "Digital Signal Processing", *
- 15 ;* Prentice-Hall, 1975 *
- 16 ;* *
- 17 ;* This module uses registers as follows: *
- 18 ;* r0 - *
- 19 ;* r1 - *
- 20 ;* r4 - *
- 21 ;* r5 - *
- 22 ;* r6 - *
- 23 ;* *
- 24 ;* Copyright (C) 1991 by Alef Null. All rights reserved. *
- 25 ;* Author(s): Jarkko Vuori, OH2LNS *
- 26 ;* Modification(s): *
- 27 ;***************************************************************
- 28
- 236
- 237 section FFT
- 238 xdef ssi_ini,fft_i
- 239 xdef m_loop
- 240 xref m_cra,m_crb,m_tde,m_sr,m_tx
- 241
- 242 P:0000 org p:
- 243
- 568
- 569 00000400 points equ 1024
- 570
- 571 ; multiply p:(r0) (data) by p:(r1) (window) and
- 572 ; put the result to x/y:(r2) (destination)
- 573 winblk macro dest
- 574 m move p:(r0)+,x0
- 575 m move p:(r1)+,x1
- 576 m mpyr x0,x1,a
- 577 m do #points-1,_endloop
- 578 m move p:(r0)+,x0
- 579 m move p:(r1)+,x1
- 580 m mpyr x0,x1,a a,dest:(r2)+
- 581 m _endloop
- 582 m move a,dest:(r2)+
- 583 m endm
- 584
- 585
- 586 ;****************************
- 587 ;* SSI initialization *
- 588 ;****************************
- 589 ssi_ini
-
-
- Motorola DSP56000 Macro Cross Assembler Version 2.02 91-08-11 13:44:22 fft.asm Page 2
- FFT transform and periodogram calculation
-
-
- 590 ; initialize SSI,
- 591 IF !0
- 592 P:0000 08F4AC movep #$4000,x:m_cra ; 16 bit word
- 004000
- 593 P:0002 08F4AD movep #$f200,x:m_crb ; syncronous,word frame,ext clk
- 00F200
- 594 ELSE
- 597 ENDIF
- 598
- 599 P:0004 00000C rts
- 600
- 601
- 602 ;****************************
- 603 ;* ADC & FFT *
- 604 ;* initialization *
- 605 ;****************************
- 606 fft_i
- 607 ; program the A/D & D/A converter chip (TLC32044, master clock is 5.184MHz)
- 608 ; disable A/D high-pass filter, disable loopback, disable AUX IN,
- 609 ; select syncronous mode, select input span 3Vpp, insert sinx/x correction
- 610 ; lowpass cutoff frequency at 3600Hz -> TA = 9 (SCF = 288kHz)
- 611 ; sampling frequency is 8000Hz -> TB = 36
- 612 ; unit sampling correction time 0.4uS -> TA' = 2
- 613 pgmtlc %10101001,9,2,36
- 641
- 642 ; initialize input sample pointers
- 643 P:0029 67F400 move #samples,r7
- 000000
- 644 P:002B 05F427 move #points-1,m7
- 0003FF
- 645
- 646 ; and FFT average counter
- 647 P:002D 07F08E move p:NN2,a
- 000000
- 648 P:002F 5E0000 move a,y:<count
- 649 P:0030 00000C rts
- 650
- 651
- 652 ;****************************
- 653 ;* Main Loop *
- 654 ;****************************
- 655 P:0031 000086 loop wait
- 656 m_loop
- 657
- 658 ; check if one block converted
- 659 P:0032 44F400 move #>samples,x0
- 000000
- 660 P:0034 22EE00 move r7,a
- 661 P:0035 209045 cmp x0,a x0,r0
- 662 P:0036 0E2000 jne <loop
- 663
- 664 ; yes, multiply samples with window
- 665 P:0037 61F400 move #window,r1
- 000000
- 666 P:0039 62F400 move #data,r2
- 000000
- 667 P:003B 05F421 move #-1,m1
-
-
- Motorola DSP56000 Macro Cross Assembler Version 2.02 91-08-11 13:44:22 fft.asm Page 3
- FFT transform and periodogram calculation
-
-
- FFFFFF
- 668 P:003D 0462A1 move m1,m2
- 669
- 670 P:003E 0B0003 bchg #blksel,x:<status
- 671 P:003F 0E0000 jcc <fft1
- 672 winblk x
- 682 P:0049 0C0000 jmp <loop
- 683 fft1 winblk y
- 693
- 694 ; real and imaginary banks filled, so transform data
- 695 ; 129000 cycles, 6.22 mS
- 696 fftr2a points,data,coef
- 783
- 784 ; extract, scale and accumulate data
- 785 ; select accumulator
- 786 P:007D 60F400 move #accb,r0
- 000000
- 787 P:007F 0A00A4 jset #accsel,x:<status,fft2
- 000083
- 788 P:0081 60F400 move #acca,r0
- 000000
- 789 fft2
- 790
- 791 ; extract and take square
- 792 ; 1/4[(Zr(k)+Zr(N-k))^2 + (Zi(k)-Zi(N-k))^2 + Zi(N-k)+Zi(k))^2 + Zr(N-k)-Zr(k))^2]
- 793 ; = 1/2[Zr(k)^2 + Zi(k)^2 + Zr(N-k)^2 + Zi(N-k)^2]
- 794 P:0083 61F400 move #data,r1
- 000000
- 795 P:0085 62F400 move #data+points-1,r2
- 000000
- 796 P:0087 71F400 move #points/2,n1
- 000200
- 797 P:0089 233A00 move n1,n2
- 798 P:008A 0500A1 move #0,m1
- 799 P:008B 0462A1 move m1,m2
- 800
- 801 P:008C 44E100 move x:(r1),x0
- 802 P:008D 060082 do #points/2,endcopy ; k = 0..N/2
- 000096
- 803 P:008F 4EC980 mpy x0,x0,a y:(r1)+n1,y0 ; Zr(k)^2 + Zi(k)^2
- 804 P:0090 44E292 mac y0,y0,a x:(r2),x0 ; Zr(N-k)^2 + Zi(N-k)^2
- 805 P:0091 4EC282 mac x0,x0,a y:(r2)-n2,y0
- 806 P:0092 200092 mac y0,y0,a
- 807 P:0093 07E084 move p:(r0),x0 ; add to result
- 808 P:0094 200040 add x0,a
- 809 P:0095 44E111 rnd a x:(r1),x0
- 810 P:0096 07588E move a,p:(r0)+
- 811 endcopy
- 812
- 813 ; check if enought integrated
- 814 P:0097 5E8000 move y:<count,a
- 815 P:0098 44F400 move #>1,x0
- 000001
- 816 P:009A 44F444 sub x0,a #>accb,x0
- 000000
- 817 P:009C 5E0000 move a,y:<count
- 818 P:009D 0E2000 jne <loop
-
-
- Motorola DSP56000 Macro Cross Assembler Version 2.02 91-08-11 13:44:22 fft.asm Page 4
- FFT transform and periodogram calculation
-
-
- 819
- 820 ; yes, send result to host
- 821 P:009E 07F08E move p:NN2,a
- 000000
- 822 P:00A0 5E0000 move a,y:<count
- 823
- 824 P:00A1 0A00A4 jset #accsel,x:<status,fft4
- 0000A5
- 825 P:00A3 44F400 move #>acca,x0
- 000000
- 826 P:00A5 56F400 fft4 move #>points/2,a
- 000200
- 827 P:00A7 200040 add x0,a
- 828 P:00A8 21C500 move a,x1
- 829
- 830 P:00A9 0B7002 bchg #$2,x:m_pcd
- 000000
- 831 P:00AB 0D0000 jsr <putblk
- 832
- 833 ; change to new accumulator, and clear it
- 834 P:00AC 60F413 clr a #acca,r0
- 000000
- 835 P:00AE 0B0004 bchg #accsel,x:<status
- 836 P:00AF 0E8000 jcs <fft5
- 837 P:00B0 60F400 move #accb,r0
- 000000
- 838 P:00B2 060082 fft5 do #points/2,_endloop
- 0000B4
- 839 P:00B4 07588E move a,p:(r0)+
- 840 _endloop
- 841
- 842 P:00B5 0C0000 jmp <loop
- 843
- 844
- 845 ;****************************
- 846 ;* DATA - AREA *
- 847 ;****************************
- 848
- 849 Y:0000 org y:
- 850
- 851 Y:0000 000000 count ds 1
- 852
- 853 endsec
- 854
- 855 end
- 0 Errors
- 0 Warnings
-
-
-
-
-
-
-
-
-
-
-
-